package com.ccav.hrm.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.ccav.hrm.domain.TenantType;
import com.ccav.hrm.mapper.TenantTypeMapper;
import com.ccav.hrm.query.TenantTypeQuery;
import com.ccav.hrm.service.ITenantTypeService;
import com.ccav.hrm.util.PageList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 租户(机构)类型表 服务实现类
 * </p>
 *
 * @author yhptest
 * @since 2020-06-22
 */
@Service
public class TenantTypeServiceImpl extends ServiceImpl<TenantTypeMapper, TenantType> implements ITenantTypeService {
    @Autowired
    private TenantTypeMapper tenantTypeMapper;
    @Override
    public PageList<TenantType> selectPageList(TenantTypeQuery query) {
        //分页对象，只要我们调用mapper的时候传入了这个对象，mybatisplus会给我们做自动分页，我们可以不做分页limit
        Page<TenantType> page = new Page<>(query.getPage(),query.getRows());

        //返回满足条件当前页数据
        List<TenantType> datas =  tenantTypeMapper.loadPageList(page,query);
        if(page.getTotal()<1){
            return new PageList<>();
        }
        return new PageList<>(page.getTotal(),datas);
    }
}
